package com.sunwayworld.basemodule.samplemanage.change.service.impl;

import com.sunwayworld.basemodule.samplemanage.change.bean.LimsLocationChangeBean;
import com.sunwayworld.basemodule.samplemanage.change.dao.LimsLocationChangeDao;
import com.sunwayworld.basemodule.samplemanage.change.service.LimsLocationChangeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.sunwayworld.framework.at.annotation.AuditTrailType;
import com.sunwayworld.framework.at.annotation.AuditTrailEntry;
import com.sunwayworld.framework.spring.annotation.GikamBean;

import com.sunwayworld.framework.context.ApplicationContextHelper;
import com.sunwayworld.framework.restful.data.RestJsonWrapperBean;

@Repository
@GikamBean
public class LimsLocationChangeServiceImpl implements LimsLocationChangeService {

    @Autowired
    private LimsLocationChangeDao limsLocationChangeDao;

    @Override
    @SuppressWarnings("unchecked")
    public LimsLocationChangeDao getDao() {
        return limsLocationChangeDao;
    }

    @Override
    @Transactional
    @AuditTrailEntry(AuditTrailType.INSERT)
    public Long insert(RestJsonWrapperBean jsonWrapper) {
        LimsLocationChangeBean limsLocationChange = jsonWrapper.parseUnique(LimsLocationChangeBean.class);
        limsLocationChange.setId(ApplicationContextHelper.getNextIdentity());
        getDao().insert(limsLocationChange);
        return limsLocationChange.getId();
    }

}
